﻿using CampusTrade.Dao;
using CampusTrade.Pojo;
using Furion.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CampusTrade.Service
{
    public class UserService : ITransient
    {
        private readonly UserDao userDao;
        public UserService(UserDao userDao)
        {
            this.userDao = userDao;
        }
        /**
         * 添加用户
         */
        public long addUser(User user)
        {
            return userDao.add(user);
        }

        /**
         * 通过id查找用户
         */
        public User selectUserById(long id)
        {
            return userDao.selectById(id);
        }
        /**
         * 通过openid查找用户
         */
        public User selectUserByOpenId(string openId)
        {
            return userDao.selectByOpenId(openId);
        }
        /**
        * 更新用户数据
        */
        public int updateUserInfo(User user)
        {
            return userDao.update(user);
        }
        /**
        * 根据id删除用户数据
        */
        public int deleteUser(long id)
        {
            return userDao.delete(id);
        }
    }
}
